package com.zhuoyian.analysis.service;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Base64;
import android.util.Log;

import com.zhuoyian.analysis.util.StaticSettings;

public class BrowserAnalysisService extends BaseService {

	public void send(String json) {
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("PBindKey", StaticSettings.getKey()));
		params.add(new BasicNameValuePair("log", new String(Base64.encode(json.getBytes(), Base64.DEFAULT))));
		getJsonObjectRequest(GetAPIUrl("log"), new Handler(Looper.getMainLooper()){
			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);
				switch (msg.what) {
				case StaticSettings.RESULT_ERROR:
					Log.i("BrowserAnalysisService", "RESULT_ERROR");
					break;
				case StaticSettings.RESULT_OK:
					Log.i("BrowserAnalysisService", "RESULT_OK");
					break;

				default:
					break;
				}
			}
		}, params);
		
		//http://test.zhuoyian.com/Api/log?PBindKey=&log=
	}
}
